/*
    FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
    All rights reserved

    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.

    This file is part of the FreeRTOS distribution.

    FreeRTOS is free software; you can redistribute it and/or modify it under
    the terms of the GNU General Public License (version 2) as published by the
    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.

    ***************************************************************************
    >>!   NOTE: The modification to the GPL is included to allow you to     !<<
    >>!   distribute a combined work that includes FreeRTOS without being   !<<
    >>!   obliged to provide the source code for proprietary components     !<<
    >>!   outside of the FreeRTOS kernel.                                   !<<
    ***************************************************************************

    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  Full license text is available on the following
    link: http://www.freertos.org/a00114.html

    ***************************************************************************
     *                                                                       *
     *    FreeRTOS provides completely free yet professionally developed,    *
     *    robust, strictly quality controlled, supported, and cross          *
     *    platform software that is more than just the market leader, it     *
     *    is the industry's de facto standard.                               *
     *                                                                       *
     *    Help yourself get started quickly while simultaneously helping     *
     *    to support the FreeRTOS project by purchasing a FreeRTOS           *
     *    tutorial book, reference manual, or both:                          *
     *    http://www.FreeRTOS.org/Documentation                              *
     *                                                                       *
    ***************************************************************************

    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
    the FAQ page "My application does not run, what could be wrong?".  Have you
    defined configASSERT()?

    http://www.FreeRTOS.org/support - In return for receiving this top quality
    embedded software for free we request you assist our global community by
    participating in the support forum.

    http://www.FreeRTOS.org/training - Investing in training allows your team to
    be as productive as possible as early as possible.  Now you can receive
    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
    Ltd, and the world's leading authority on the world's leading RTOS.

    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
    including FreeRTOS+Trace - an indispensable productivity tool, a DOS
    compatible FAT file system, and our tiny thread aware UDP/IP stack.

    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.

    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
    licenses offer ticketed support, indemnification and commercial middleware.

    http://www.SafeRTOS.com - High Integrity Systems also provide a safety
    engineered and independently SIL3 certified version for use in safety and
    mission critical applications that require provable dependability.

    1 tab == 4 spaces!
*/

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

/*-----------------------------------------------------------
 * Application specific definitions.
 *
 * These definitions should be adjusted for your particular hardware and
 * application requirements.
 *
 * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
 * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
 *
 * See http://www.freertos.org/a00110.html.
 *----------------------------------------------------------*/

#define configUSE_PREEMPTION 1    // 调度器方式0：协助式 1：抢占式
#define configUSE_TICKLESS_IDLE 0 // 启用低功耗tickless模式
#define configCPU_CLOCK_HZ (SystemCoreClock)
#define configTICK_RATE_HZ ((TickType_t)1000)         // 系统节拍设置
#define configMAX_PRIORITIES 5                        // 最大优先级
#define configMINIMAL_STACK_SIZE ((unsigned short)90) // 空闲任务栈大小
#define configMAX_TASK_NAME_LEN 20                    // 任务名的字符串长度
#define configUSE_16_BIT_TICKS 0                      // 系统节拍计数器变量类型
#define configIDLE_SHOULD_YIELD 1                     // 空闲任务放弃cpu使用权，交给其他同优先级的用户任务
#define configUSE_TASK_NOTIFICATIONS 1                // 使能任务间直接的消息传递，包含信号量，事件标志组和消息邮箱。
#define configUSE_MUTEXES 1                           // 使能互斥信号量
#define configUSE_RECURSIVE_MUTEXES 1                 // 使能递归互斥信号量
#define configUSE_COUNTING_SEMAPHORES 1               // 使能计数型信号量
#define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ // 此配置将在以后的版本中被删除，建议用户不要再使用。
/*   configQUEUE_REGISTRY_SIZE
通过此定义来设置可以注册的信号量和消息队列个数。
队列注册有两个目的，这两个目的都与内核调试有关：
1、注册队列的时候，可以给队列起一个名字，当使用调试组件的时候，通过名字可以很容易的区分不同
队列。
2、通过队列的相关信息，调试器可以很容易定位队列和信号量，能够定位信号量是因为 FreeRTOS 信号
量也是基于队列实现的。
当然，如果用户没有使用内核方面的调试器，这个宏定义是没有意义的。
*/
#define configQUEUE_REGISTRY_SIZE 8
#define configUSE_QUEUE_SETS 0                    // 使能消息队列。
#define configUSE_TIME_SLICING 0                  // 使能时间片调度
#define configUSE_NEWLIB_REENTRANT 0              // 每个任务创建的时候将分配 Newlib 的重入结构体。
#define configENABLE_BACKWARD_COMPATIBILITY 0     // 使能新版本对老版本的兼容特性，即向后兼容或者说向下兼容。
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 // 此配置用于定义线程局部指针变量的个数。

/* Used memory allocation (heap_x.c) */
#define configFRTOS_MEMORY_SCHEME 4
/* Tasks.c additions (e.g. Thread Aware Debug capability) */
#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1 // task的扩充

/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 0           // 支持静态分配
#define configSUPPORT_DYNAMIC_ALLOCATION 1          // 支持动态分配
#define configTOTAL_HEAP_SIZE ((size_t)(10 * 1024)) // 总堆的大小
#define configAPPLICATION_ALLOCATED_HEAP 0

/* Hook function related definitions. */
#define configUSE_IDLE_HOOK 0 // 空闲钩子函数
#define configUSE_TICK_HOOK 0 // 使能滴答定时器中断里面执行的钩子函数
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0

/* Run time and task stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS 0
#define configUSE_TRACE_FACILITY 1
#define configUSE_STATS_FORMATTING_FUNCTIONS 0

/* Task aware debugging. */
#define configRECORD_STACK_HIGH_ADDRESS 1

/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES 2

/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)

/* Define to trap errors during development. */
#define configASSERT(x)           \
    if ((x) == 0)                 \
    {                             \
        taskDISABLE_INTERRUPTS(); \
        for (;;)                  \
            ;                     \
    }

/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_eTaskGetState 0
#define INCLUDE_xTimerPendFunctionCall 1
#define INCLUDE_xTaskAbortDelay 0
#define INCLUDE_xTaskGetHandle 0
#define INCLUDE_xTaskResumeFromISR 1

/* Cortex-A specific definitions. */
#define configMAX_API_CALL_INTERRUPT_PRIORITY 20

/* Systick definitions */
#define configSETUP_TICK_INTERRUPT()                                                                                  \
    do                                                                                                                \
    {                                                                                                                 \
        void SystemSetupSystick(uint32_t tickRateHz, void *tickHandler, uint32_t intPriority);                        \
        /* Setup systick with lowest priority */                                                                      \
        SystemSetupSystick(configTICK_RATE_HZ, (void *)FreeRTOS_Tick_Handler, configUNIQUE_INTERRUPT_PRIORITIES - 2); \
    } while (0)
#define configCLEAR_TICK_INTERRUPT()       \
    do                                     \
    {                                      \
        void SystemClearSystickFlag(void); \
        SystemClearSystickFlag();          \
    } while (0)

/* Definitions that map the FreeRTOS port exception handlers to startup handler names. */
#define FreeRTOS_IRQ_Handler IRQ_Handler
#define FreeRTOS_SWI_Handler SVC_Handler

/*
 * If define configUSE_TASK_FPU_SUPPORT to 1, the task will start without a floating
 * point context. A task that uses the floating point hardware must call vPortTaskUsesFPU()
 * before executing any floating point instructions.
 */
#ifndef configUSE_TASK_FPU_SUPPORT
#define configUSE_TASK_FPU_SUPPORT 1
#endif

/* GIC information defintions. */
#define configINTERRUPT_CONTROLLER_BASE_ADDRESS 0x00a01000UL
#define configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET 0x1000UL
#define configUNIQUE_INTERRUPT_PRIORITIES 32

#endif /* FREERTOS_CONFIG_H */
